﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class service_rjcz1 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["username"] != null && Session["userpwd"] != null)
            {
                this.hidName.Value = Session["username"].ToString();
            }
        }
    }
    /// <summary>
    /// 软件充值Pc
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>

    protected void btnOk_pc_Click(object sender, ImageClickEventArgs e)
    {
        string username = userName_pc.Text;
        string softpwd = softPwd_pc.Text;
        string cardid = cardId_pc.Text;
        string cardpwd = cardPwd_pc.Text;
        string c = codepc.Text;
        int cardType = 1;     //leixing 
        if (sLeve.Checked)
            cardType = int.Parse(sLeve.Value);
        else if (hLeve.Checked)
            cardType = int.Parse(hLeve.Value);
        else
            cardType = 0;
        string code = (string)Session["code"];
        if (c.Trim().ToLower() == code.Trim())
        {
            emoneybussiness.emoneybusiness service = new emoneybussiness.emoneybusiness();
            if (!service.CheckUserName(username, softpwd))
            {
                ClientScript.RegisterStartupScript(GetType(), "a", "alert('充值失败,软件用户名或密码有误');", true);
            }
            else
            {
                string result = service.DOUserAddFeeNew(username, cardType, cardid, cardpwd);
                ClientScript.RegisterStartupScript(GetType(), "a", "alert('" + result + "');", true);
                softPwd_pc.Text = "";
                cardPwd_pc.Text = "";
                codepc.Text = "";
            }
        }
        else
        {
            codepc.Text = "";
            ClientScript.RegisterStartupScript(GetType(), "a", "alert('验证码输入不正确');", true);
        }
    }
    /// <summary>
    /// 手机版
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnOk_mobile_Click(object sender, ImageClickEventArgs e)
    {
        string mob = mobile.Text;
        int mobpwd = int.Parse(mobile_pwd.Text);
        string cardid = cardId_mobile.Text;
        string cardpwd = cardPwd_mobile.Text;
        string c = (string)Session["code"];
        string code = codemobile.Text;
        if (code.Trim().ToLower() == c.Trim())
        {
            try
            {
                emoneybussiness.emoneybusiness service = new emoneybussiness.emoneybusiness();
                string result = service.DOMobileAddFee(mob, mobpwd, cardid, cardpwd);
                ClientScript.RegisterStartupScript(GetType(), "a", "alert('" + result + "');", true);
                mobile_pwd.Text = "";
                cardPwd_mobile.Text = "";
                codemobile.Text = "";
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(GetType(), "a", "alert('服务器忙，请重试');", true);
            }

        }
        else
        {
            codemobile.Text = "";
            ClientScript.RegisterStartupScript(GetType(), "a", "alert('验证码输入不正确');", true);
        }
    }
    /// <summary>
    /// 手机版换购验证
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnOk_free_Click(object sender, ImageClickEventArgs e)
    {
        string id = freeId.Text;
        string pwd = freePwd.Text;
        string code = codefree.Text;
        string c = (string)Session["code"];
        if (c.Trim().ToLower() == code.Trim())
        {
            int result = 0;
            try
            {
                emoneybussiness.emoneybusiness service = new emoneybussiness.emoneybusiness();
                
                result = int.Parse(service.CheckEMUserType(id, pwd));
            }
            catch (Exception)
            {
                result = 0;
            }
            if (result > 0)
            {
                Session["pc_username"] = id;
                Session["pc_userpwd"] = pwd;
                freeId.Text = "";
                codefree.Text = "";
                Panel1.Visible = false;
                Panel2.Visible = false;
                Panel3.Visible = false;
                Panel4.Visible = true;
            }
            else
            {
                ClientScript.RegisterStartupScript(GetType(), "a", "alert('对不起，您之前不是益盟的付费用户，不能享受老用户优惠，请先拨打4006708886购买360元/年决策版或880元/年主力版。');", true);
            }
        }
        else
        {
            codefree.Text = "";
            ClientScript.RegisterStartupScript(GetType(), "a", "alert('验证码输入不正确');", true);
        }
    }
    /// <summary>
    /// 手机版换购
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btn_mobileHG_submit_Click(object sender, ImageClickEventArgs e)
    {
        string username = mobileHG_username.Text;
        string pwd = mobileHG_password.Text;
        string cardnum = mobileHG_cardnum.Text;
        string cardpwd = mobileHG_cardpass.Text;
        string code = this.mobileHG_code.Text;
        string c = (string)Session["code"];
        if (c.Trim().ToLower() == code.Trim())
        {
            try
            {
                emoneybussiness.emoneybusiness service = new emoneybussiness.emoneybusiness(); 
                //方法
                string result = service.DOMobileAddFee1(username, int.Parse(pwd), cardnum, cardpwd, Session["pc_username"].ToString(), Session["pc_userpwd"].ToString());
                ClientScript.RegisterStartupScript(GetType(), "a", "alert('" + result + "');", true);
                mobileHG_cardpass.Text = "";
                mobileHG_code.Text = "";
                mobileHG_password.Text = "";
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(GetType(), "a", "alert('服务器忙，请重试');", true);
            }
        }
        else
        {
            mobileHG_code.Text = "";
            ClientScript.RegisterStartupScript(GetType(), "a", "alert('验证码输入不正确');", true);
        }
    }
    /// <summary>
    ///pc版重置
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnReset_pc_Click(object sender, ImageClickEventArgs e)
    {
        userName_pc.Text = "";
        softPwd_pc.Text = "";
        cardId_pc.Text = "";
        cardPwd_pc.Text = "";
        codepc.Text = "";
    }
    /// <summary>
    /// 手机重置
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnReset_mobile_Click(object sender, ImageClickEventArgs e)
    {
        mobile.Text = "";
        mobile_pwd.Text = "";
        cardId_mobile.Text = "";
        cardPwd_mobile.Text = "";
        codemobile.Text = "";

    }
    /// <summary>
    /// radiobutton改变
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void addfee_pc_CheckedChanged(object sender, EventArgs e)
    {
        Panel1.Visible = true;
        Panel2.Visible = false;
        Panel3.Visible = false;
        Panel4.Visible = false;
    }
    /// <summary>
    /// 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void addfee_mobile_CheckedChanged(object sender, EventArgs e)
    {
        Panel1.Visible = false;
        Panel2.Visible = true;
        Panel3.Visible = false;
        Panel4.Visible = false;
    }
    protected void addfee_HG_CheckedChanged(object sender, EventArgs e)
    {
        Panel1.Visible = false;
        Panel2.Visible = false;
        Panel3.Visible = true;
        Panel4.Visible = false;
    }
    /// <summary>
    /// 手机版换购验证页面重置
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnReset_free_Click(object sender, ImageClickEventArgs e)
    {
        freeId.Text = "";
        codefree.Text = "";
        freePwd.Text = "";
    }
    /// <summary>
    /// 手机版换购页面重置
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btn_mobileHG_reset_Click(object sender, ImageClickEventArgs e)
    {
        mobileHG_username.Text = "";
        mobileHG_cardpass.Text = "";
        mobileHG_code.Text = "";
        mobileHG_password.Text = "";
        mobileHG_cardnum.Text = "";
    }
}